//
// Created by sjjmw on 2/23/2022.
//

#ifndef LEETCODE__17_H
#define LEETCODE__17_H


#include "iostream"
int main(){
    int n;
    while (scanf("%d",&n) != EOF /* condition */)
    {
        int max_num,max_cnt=1;
        int last_num,last_num_cnt=1;
        scanf("%d",&max_num);
        last_num=max_num;
        n--;
        while(n){
            int a;
            scanf("%d",&a);
            if(last_num==a){
                last_num_cnt++;
            }else{
                last_num_cnt=1;
            }
            if(last_num_cnt>=max_cnt){
                max_cnt=last_num_cnt;
                max_num=last_num;
            }
            last_num=a;
            n--;
        }
        printf("%d %d\n",max_num,max_cnt);
    }
    return 0;
}


#endif //LEETCODE__17_H
